<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchFormDict").submit();
        	return false;
        }
        //添加规格链接验证，是否选中左侧药品名称字典
        function vilidateRows() {
            var table = document.getElementById("contentTable1");//获取表格元素
            var allTrs = table.getElementsByTagName("tr");//获取表格的行元素
            if (allTrs.length == 0) {
                 return;
            }
            for(var i=0;i< allTrs.length;i++){
                var tr= allTrs[i];
                if(hasClass(tr,'table-selected')){
                    loadDiv('rigthCenterDiv', '${ctx}/drug/drugDict/form');
                }
            }
            toastr.error("请先选择药品名称字典！");
            //判断某个元素是否有指定的样式
            function hasClass(element, cls) {
                return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
            }
        }
</script>
<div class="app">
    <section class="layout">
        <section class="main-content col-lg-3">
            <div class="content-wrap" id="leftCenterDiv">
                <div class="wrapper" style="bottom: 50px;">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#" onclick="loadDiv('mainCenterDiv','${ctx}/drug/drugNameDict/index')">药品名称字典</a>
                        </li>
                        <li>
                            <a href="#" onclick="loadDiv('leftCenterDiv','${ctx}/drug/drugNameDict/form')">添加药品名称</a>
                        </li>
                    </ul>

                    <%--左侧药品字典列表--%>
                    <section class="panel panel-default">
                        <div class="panel-body">
                            <div class="table-responsive no-border">
                                <div class="datatable-top">
                                    <div class="pull-left">
                                        <%--药品查询--%>
                                        <form:form id="searchFormDict" modelAttribute="drugNameDict"
                                                   onsubmit="return loadDivForm('mainCenterDiv','searchFormDict','${ctx}/drug/drugNameDict/index');"
                                                   method="post" class="form-inline">
                                            <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                                            <input id="pageSize" name="pageSize" type="hidden"
                                                   value="${page.pageSize}"/>
                                            <label>药品代码:</label><form:input path="drugCode" htmlEscape="false"
                                                                           maxlength="50" class="form-control"/>
                                            &nbsp;&nbsp;</br><label>药品名称:</label><form:input path="drugName"
                                                                                            htmlEscape="false"
                                                                                            maxlength="50"
                                                                                            class="form-control"/>
                                            &nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
                                        </form:form>
                                    </div>
                                </div>

                                <%--药品名称列表--%>
                                <div class="container-fluid">
                                    <table id="contentTable1" class="table table-bordered mg-t datatable">
                                        <thead>
                                        <tr>
                                            <th>药品代码</th>
                                            <th>药品名称</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <c:forEach items="${page.list}" var="drugNameDict">
                                        <tr onclick="loadDiv('rigthCenterDiv','${ctx}/drug/drugDict/dialog?drugCode=${drugNameDict.drugCode}&drugName=${drugNameDict.drugName}')">
                                            <td> ${drugNameDict.drugCode}</td>
                                            <td> ${drugNameDict.drugName}</td>
                                        </tr>
                                        </c:forEach>
                                    </table>
                                    <div class="pagination">${page}</div>
                                </div>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </section>

        <%--右侧药品规格字典列表--%>
        <section class="main-content col-lg-8">
            <div class="content-wrap" id="rigthCenterDiv">
                <div class="wrapper" style="bottom: 50px;">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#" onclick="loadDiv('rigthCenterDiv','${ctx}/drug/drugDict/dialog')">规格列表</a>
                        </li>
                        <li>
                            <a href="#" onclick="vilidateRows()">添加规格</a>
                        </li>
                        <%--<li>--%>
                            <%--<a href="#" onclick="loadDiv('rigthCenterDiv','${ctx}/drug/drugNameDict/saveDrugNameDictExcel')">导入NameDict</a>--%>
                        <%--</li>--%>
                        <%--<li>--%>
                            <%--<a href="#" class="btn btn-primary" onclick="loadDiv('rigthCenterDiv','${ctx}/drug/drugNameDict/saveDrugDictExcel')">导入DrugDict</a>--%>
                        <%--</li>--%>
                        <%--<li>--%>
                            <%--<a href="#" class="btn btn-primary" onclick="loadDiv('rigthCenterDiv','${ctx}/drug/drugNameDict/saveInfoPriceExcel')">导入info和价表</a>--%>
                        <%--</li>--%>
                    </ul>
                </div>
            </div>
        </section>
    </section>
</div>

